-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(color): allow all valid CSS colors #2381
Conversation
Add support for the following notation styles - Hex number colors - hsl / hsla color functions - named colors - space separated function notation - decimal numbers in colors - percentages in colors - exponent numbers - deg / rad / turn unit in hue DEPREDATED: Use Color.parseString() instead of Color.parseRgbString()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment but you can implement it if you'd like
*/ | ||
this.parseString = function(colorString) { | ||
// IE occasionally returns named colors instead of RGB(A) values | ||
if (standards.cssColors[colorString] || colorString === 'transparent') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have transparent
be a named color with vales of [0, 0, 0]
rather than special casing it three times? (first in the if
, again with the color assignment of || [0,0,0]
, and last with the alpha). We could just only special case the alpha
if it's transparent if it was a named color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about that, but I don't think that's all that clean of a solution. I had it in a separate if statement at first. I can put that back in if you prefer. Personally, this seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update pr title to feat
as we are deprecating a public API
Add support for the following notation styles
DEPREDATED: Color.parseRgbString() is replaced by Color.parseString()
This PR is a prerequisite for #2334
Reviewer checks
Required fields, to be filled out by PR reviewer(s)